﻿<%@ Page Title="" Language="C#" MasterPageFile="~/presentation/MasterPage.Master"
    AutoEventWireup="true" CodeBehind="StravovaniForm.aspx.cs" Inherits="ISHotel.presentation.StravovaniForm" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div align="left" class="art-blockcontent-body">
        <table>
            <tr>
                <td>
                </td>
                <td align="center">
                    <asp:Label ID="LabelNoveStravovani" runat="server" Text="Nové stravování"></asp:Label>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelNazev" runat="server" Text="Název stravování:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBoxNazev" runat="server" MaxLength="100"></asp:TextBox>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidatorNazev" runat="server" ErrorMessage="*"
                        ControlToValidate="TextBoxNazev"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelCena" runat="server" Text="Cena:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBoxCena" runat="server" MaxLength="5"></asp:TextBox>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidatorCena" runat="server" ErrorMessage="*"
                        ControlToValidate="TextBoxCena"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Jen čísla!"
                        ValidationExpression="\d+" ControlToValidate="TextBoxCena">
                    </asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td align="center">
                    <asp:Button ID="ButtonVlozStravovani" runat="server" Text="Vlož" OnClick="ButtonVlozStravovani_Click" />
                </td>
                <td>
                </td>
            </tr>
        </table>
        <asp:ObjectDataSource ID="ODS_ListStravovani" runat="server" SelectMethod="Select"
            TypeName="ISHotel.Database.StravovaniTable"></asp:ObjectDataSource>
        <br />
        <asp:Label ID="LabelErr" runat="server" Visible="True" ForeColor="Red"></asp:Label>
        <br />
        <br />
        <asp:GridView ID="GridViewStravovani" runat="server" AutoGenerateColumns="False"
            DataSourceID="ODS_Stravovani" AllowPaging="True" DataKeyNames="id_stravovani">
            <Columns>
                <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:ImageButton ID="ImageButtonDel" runat="server" CommandArgument='<%# Eval("id_stravovani") %>'
                            CommandName="DeleteStravovani" OnCommand="button_Command" ImageUrl="~/images/delete.jpg"
                            OnClientClick="javascript: return confirm(&apos;Opravdu smazat stravovani?&apos;);" />
                    </ItemTemplate>
                </asp:TemplateField>                
                <asp:BoundField DataField="nazev_stravovani" HeaderText="Název stravování" SortExpression="nazev_stravovani" />
                <asp:BoundField DataField="cena_stravovani" HeaderText="Cena stravování" SortExpression="cena_stravovani" />
                <asp:CommandField ShowSelectButton="True" HeaderText="Upravit" SelectImageUrl="../images/pencil.gif"
                    ButtonType="Image" ItemStyle-HorizontalAlign="Center" />
            </Columns>
        </asp:GridView>
        <asp:ObjectDataSource ID="ODS_Stravovani" runat="server" SelectMethod="Select" TypeName="ISHotel.Database.StravovaniTable"
            DeleteMethod="Delete">
            <DeleteParameters>
                <asp:Parameter Name="id_stravovani" Type="Int32" />
            </DeleteParameters>
        </asp:ObjectDataSource>
        <br />
        <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="300px" AutoGenerateRows="False"
            DataSourceID="ODS_StravovaniDetail" DataKeyNames="id_stravovani">
            <Fields>
                <asp:TemplateField HeaderText="Název stravování" SortExpression="nazev_stravovani">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("nazev_stravovani") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("nazev_stravovani") %>'
                            MaxLength="100"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorJmenoDetail" runat="server"
                            ErrorMessage="*" ControlToValidate="TextBox2" ValidationGroup="Detail"></asp:RequiredFieldValidator>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Cena" SortExpression="cena_stravovani">
                    <ItemTemplate>
                        <asp:Label ID="Label6" runat="server" Text='<%# Bind("cena_stravovani") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("cena_stravovani") %>' MaxLength="5"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorPSCDetail" runat="server" ErrorMessage="*"
                            ControlToValidate="TextBox6" ValidationGroup="Detail"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidatorPSC3Detail" runat="server"
                            ErrorMessage="Jen čísla!" ValidationExpression="\d+" ControlToValidate="TextBox6"
                            ValidationGroup="Detail">
                        </asp:RegularExpressionValidator>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowEditButton="True" CausesValidation="True" ValidationGroup="Detail" />
            </Fields>
        </asp:DetailsView>
        <asp:ObjectDataSource ID="ODS_StravovaniDetail" runat="server" SelectMethod="Select"
            UpdateMethod="Update" OnUpdated="StravovaniDetail_OnUpdated" DataObjectTypeName="ISHotel.Database.Stravovani"
            TypeName="ISHotel.Database.StravovaniTable">
            <SelectParameters>
                <asp:ControlParameter PropertyName="SelectedValue" Type="int32" Name="id_stravovani"
                    ControlID="GridViewStravovani"></asp:ControlParameter>
            </SelectParameters>
        </asp:ObjectDataSource>
    </div>
</asp:Content>
